<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Session;
use App\Services\QuestionService;
use Illuminate\Http\Request;

class FeedBackController extends Controller{
	public function list(Request $request){
		$username  = Session::get('username');

		if(!$username){
			return redirect('/admin/login');
		}else{
			$data['action'] = $request->input('action') ? addslashes($request->input('action')) : '';

			$question = new QuestionService;

			$data['page_size_list'] = array(20,25,50,100);
			$data['page_size'] = $request->input('page_size') ? intval($request->input('page_size')) : 3;
			$data['keywords'] = $request->input('keywords') ? addslashes($request->input('keywords')) : '';
			$data['username'] = $username;

			if($data['action'] == ''){
				$data['qlist'] = $question->getQuestionList($data['page_size']);
			}else{
				$data['qlist'] = $question->searchQuestionList($data['page_size'],$data['keywords']);
			}
			
				
			
			

			return view('admin.question.list',$data);
		}
	}
	public function del($id){
		$data['isshow'] = 0;
		$question = new QuestionService;
		$res = $question->delQuestion($id,$data);
		if($res){
			$data = array('code'=>200);
		}else{
			$data = array('code'=>400);
		}

		return response()->json($data);
	}
}